<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@ include file="common.jsp" %>
<%            // Main Application Logic Comes Here

%>

<HTML>
    <c:set var="title" value="MIC Tycoon ~ Manage Project Page"/>
    <%@ include file="htmlheader.jsp" %>

    <body>
        <div id="resolution">

            <%@ include file="header.jsp" %>
            <%@ include file="menu.jsp" %>

            <div class="content">

                <div id="manage_project">

                    <img src="<%= realURL("", url)%>images/titles/manage-proj.png" border="0" />


                    <!-- PLAYER'S  PROJECTS -->

                    <c:forEach items="${project_list}" var="project">
                        <br/>
                        <div>
                            <div id="paper-holder-landscape-small">

                                <div id="deadline-holder-landscape">${project.due_turn}</div>

                                <div id="paper-content-over-project">
                                    <c:if test="${project.man_hours_dot_net ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                    <c:if test="${project.man_hours_dot_net !=0}"><div id="manhours-on">${project.man_hours_dot_net}</div></c:if>
                                    <c:if test="${project.man_hours_c_sharp ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                    <c:if test="${project.man_hours_c_sharp !=0}"><div id="manhours-on">${project.man_hours_c_sharp}</div></c:if>
                                    <c:if test="${project.man_hours_jsp ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                    <c:if test="${project.man_hours_jsp !=0}"><div id="manhours-on">${project.man_hours_jsp}</div></c:if>
                                    <c:if test="${project.man_hours_php ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                    <c:if test="${project.man_hours_php !=0}"><div id="manhours-on">${project.man_hours_php}</div></c:if>
                                    <c:if test="${project.man_hours_ruby ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                    <c:if test="${project.man_hours_ruby !=0}"><div id="manhours-on">${project.man_hours_ruby}</div></c:if>
                                    <c:if test="${project.man_hours_mysql ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                    <c:if test="${project.man_hours_mysql !=0}"><div id="manhours-on">${project.man_hours_mysql}</div></c:if>
                                    <c:if test="${project.man_hours_mssql ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                    <c:if test="${project.man_hours_mssql !=0}"><div id="manhours-on">${project.man_hours_mssql}</div></c:if>
                                    <c:if test="${project.man_hours_oracle ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                    <c:if test="${project.man_hours_oracle !=0}"><div id="manhours-on">${project.man_hours_oracle}</div></c:if>
                                </div>

                                <div id="paper-content-landscape">
                                    <b>Project </b>[<b>#${project.project_id}</b>] ${project.company.name}
                                    <br/>
                                    <b>Payout:</b> ${project.bidded_price_string}

                                    <br/> <b>Remaining Hours:</b>
                                    <img src="<%= realURL("", url)%>images/logos/logo-levels-h.png" border="0" />
                                    <br /><br/>

                                    <a href ="<%= realURL("", url)%>servlet/project/${project.project_id}/assign">
                                        <input type="button" value="Assign Employee to Project"/>
                                    </a>

                                    <a href ="<%= realURL("", url)%>servlet/project/${project.project_id}/outsource">
                                        <input type="button" value="Outsource Project"/>
                                    </a>

                                    <c:if test="${project.submitable == true}">
                                        <a href ="<%= realURL("", url)%>servlet/project/${project.project_id}/submit">
                                            <input type="button" value="Submit Project"/>
                                        </a>
                                    </c:if>
                                </div>
                            </div>

                            <!-- PROJECT INJECT HERE -->

                            <c:if test="${project.inject != null}">
                                <div id="paper-injects">
                                    <div id="project_inject">
                                        <p><b>Change of Scope!</b></p>

                                        <c:if test="${project.inject.dot_net !=0}"><div id="inject_item">Add ${project.inject.dot_net} hours of .Net</div></c:if>
                                        <c:if test="${project.inject.c_sharp !=0}"><div id="inject_item">Add ${project.inject.c_sharp} hours of C#</div></c:if>
                                        <c:if test="${project.inject.jsp !=0}"><div id="inject_item">Add ${project.inject.jsp} hours of JSP</div></c:if>
                                        <c:if test="${project.inject.php !=0}"><div id="inject_item">Add ${project.inject.php} hours of PHP</div></c:if>
                                        <c:if test="${project.inject.ruby !=0}"><div id="inject_item">Add ${project.inject.ruby} hours of Ruby</div></c:if>
                                        <c:if test="${project.inject.mysql !=0}"><div id="inject_item">Add ${project.inject.mysql} hours of MySQL</div></c:if>
                                        <c:if test="${project.inject.mssql !=0}"><div id="inject_item">Add ${project.inject.mssql} hours of MsSQL</div></c:if>
                                        <c:if test="${project.inject.oracle !=0}"><div id="inject_item">Add ${project.inject.oracle} hours of Oracle</div></c:if>
                                        <p>
                                            <a href="<%= realURL("", url)%>servlet/project/${project.project_id}/accept_inject">
                                                Accept
                                            </a>
                                            |
                                            <a href="<%= realURL("", url)%>servlet/project/${project.project_id}/decline_inject">
                                                Decline
                                            </a>
                                        </p>
                                    </div>
                                </div>
                            </c:if>

                        </div>
                        <c:forEach items="${player_generated_outsource_projects}" var="outsource_project">
                            <c:if test="${project.project_id == outsource_project.parent_id}">
                                <!-- OUTSOURCED PROJECT -->
                                <br/>
                                <div id="paper-holder-landscape-oursourced">
                                    <div id="deadline-holder-landscape">${outsource_project.due_turn}</div>
                                    <div id="paper-content-over-project">

                                    </div>

                                    <div id="paper-content-over-project">
                                        <c:if test="${outsource_project.man_hours_dot_net ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                        <c:if test="${outsource_project.man_hours_dot_net !=0}"><div id="manhours-on">${outsource_project.man_hours_dot_net}</div></c:if>
                                        <c:if test="${outsource_project.man_hours_c_sharp ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                        <c:if test="${outsource_project.man_hours_c_sharp !=0}"><div id="manhours-on">${outsource_project.man_hours_c_sharp}</div></c:if>
                                        <c:if test="${outsource_project.man_hours_jsp ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                        <c:if test="${outsource_project.man_hours_jsp !=0}"><div id="manhours-on">${outsource_project.man_hours_jsp}</div></c:if>
                                        <c:if test="${outsource_project.man_hours_php ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                        <c:if test="${outsource_project.man_hours_php !=0}"><div id="manhours-on">${outsource_project.man_hours_php}</div></c:if>
                                        <c:if test="${outsource_project.man_hours_ruby ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                        <c:if test="${outsource_project.man_hours_ruby !=0}"><div id="manhours-on">${outsource_project.man_hours_ruby}</div></c:if>
                                        <c:if test="${outsource_project.man_hours_mysql ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                        <c:if test="${outsource_project.man_hours_mysql !=0}"><div id="manhours-on">${outsource_project.man_hours_mysql}</div></c:if>
                                        <c:if test="${outsource_project.man_hours_mssql ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                        <c:if test="${outsource_project.man_hours_mssql !=0}"><div id="manhours-on">${outsource_project.man_hours_mssql}</div></c:if>
                                        <c:if test="${outsource_project.man_hours_oracle ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                        <c:if test="${outsource_project.man_hours_oracle !=0}"><div id="manhours-on">${outsource_project.man_hours_oracle}</div></c:if>
                                    </div>

                                    <div id="paper-content-landscape">
                                        <b>Outsourced Project </b>[<b>#${outsource_project.project_id}</b>] < <b>Parent Project [#${project.project_id}]</b>
                                        <br/>
                                        <b>Payout:</b> ${outsource_project.bidded_price_string}

                                        <hr />

                                        <br/>
                                        <img src="<%= realURL("", url)%>images/logos/logo-levels-h.png" border="0" />
                                        <br /><br />
                                        <c:choose>
                                            <c:when test="${outsource_project.taken_by ==0}">
                                                <a href ="<%= realURL("", url)%>servlet/project/${outsource_project.parent_id}/edit_outsource?project_id=${outsource_project.project_id}">
                                                    <input type="button" value="Edit"/>
                                                </a>

                                                <a href ="<%= realURL("", url)%>servlet/project/${outsource_project.parent_id}/cancel_outsource?project_id=${outsource_project.project_id}">
                                                    <input type="button" value="Cancel"/>
                                                </a>
                                            </c:when>
                                            <c:otherwise>
                                                <c:set var="cancel_prompt" value="Are you sure you want to cancel the outsource project? \\\n\\\nCancelling the project now will result to penalty of ${outsource_project.bidded_price_string}" />
                                                <c:if test="${outsource_project.due_turn < turn.current_turn}">
                                                    <c:set var="cancel_prompt" value="Are you sure you want to cancel the outsource project? \n\nCancelling the project now will not penalize you anything" />
                                                </c:if>

                                                <form action="<%= realURL("", url)%>servlet/project/${outsource_project.parent_id}/cancel_outsource" method="GET" onSubmit="return confirm('${cancel_prompt}')">
                                                    <input type="hidden" name="project_id" value="${outsource_project.project_id}"/>
                                                    <input type="submit" value="Cancel Project"/>
                                                </form>
                                            </c:otherwise>
                                        </c:choose>

                                    </div>
                                </div>
                            </c:if>
                        </c:forEach>

                    </c:forEach>


                    <!-- PLAYER'S OUTSOURCE PROJECTS -->

                    <c:forEach items="${outsource_project_list}" var="project">
                        <!-- OUTSOURCE PROJECT -->
                        <div id="paper-holder-landscape-small">
                            <div id="paper-content-over-project">

                            </div>

                            <div id="deadline-holder-landscape">${project.due_turn}</div>

                            <div id="paper-content-over-project">
                                <c:if test="${project.man_hours_dot_net ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                <c:if test="${project.man_hours_dot_net !=0}"><div id="manhours-on">${project.man_hours_dot_net}</div></c:if>
                                <c:if test="${project.man_hours_c_sharp ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                <c:if test="${project.man_hours_c_sharp !=0}"><div id="manhours-on">${project.man_hours_c_sharp}</div></c:if>
                                <c:if test="${project.man_hours_jsp ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                <c:if test="${project.man_hours_jsp !=0}"><div id="manhours-on">${project.man_hours_jsp}</div></c:if>
                                <c:if test="${project.man_hours_php ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                <c:if test="${project.man_hours_php !=0}"><div id="manhours-on">${project.man_hours_php}</div></c:if>
                                <c:if test="${project.man_hours_ruby ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                <c:if test="${project.man_hours_ruby !=0}"><div id="manhours-on">${project.man_hours_ruby}</div></c:if>
                                <c:if test="${project.man_hours_mysql ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                <c:if test="${project.man_hours_mysql !=0}"><div id="manhours-on">${project.man_hours_mysql}</div></c:if>
                                <c:if test="${project.man_hours_mssql ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                <c:if test="${project.man_hours_mssql !=0}"><div id="manhours-on">${project.man_hours_mssql}</div></c:if>
                                <c:if test="${project.man_hours_oracle ==0}"><div id="manhours-off">&nbsp;</div></c:if>
                                <c:if test="${project.man_hours_oracle !=0}"><div id="manhours-on">${project.man_hours_oracle}</div></c:if>
                            </div>

                            <div id="paper-content-landscape">
                                <b>Project </b>[<b>#${project.project_id}</b>] ${project.creator.company_name}
                                <br/>
                                <b>Payout:</b> ${project.bidded_price_string}

                                <hr />

                                <br/>
                                <img src="<%= realURL("", url)%>images/logos/logo-levels-h.png" border="0" />
                                <br /><br />

                                <a href ="<%= realURL("", url)%>servlet/project/${project.project_id}/assign_outsource">
                                    <input type="button" value="Assign Employee to Project"/>
                                </a>

                                <c:if test="${project.submitable == true}">
                                    <a href ="<%= realURL("", url)%>servlet/project/${project.project_id}/submit_outsource">
                                        <input type="button" value="Submit Project"/>
                                    </a>
                                </c:if>

                            </div>
                        </div>
                    </c:forEach>

                </div> <!-- end of manage player project -->


            </div>
        </div>

    </BODY>
</HTML>